Setting up Habitica Locally on Docker
Git Settings for Line Endings This section is only relevant if you are using Docker on a Windows PC. *nix operating systems (Linux and Mac OS X) handle line endings differently than Windows. *nix systems use the line feed (LF) character \n, while Windows uses a combination of a carriage return and line feed, \r\n (CRLF). Since Habitica developers use a variety of operating systems, to allow for maximum compatibility, Git on Windows must be set up to ensure that only LF line endings are committed to the repo. How you set this up depends on whether you will be doing all your code editing directly in Windows or in the Docker container. The appropriate setting can be chosen when installing Git (see the screenshot but read on before you chose an option) or afterwards using a simple command-line tool. If you will be doing all your code editing in the Docker container, then when presented with the "Configuring the line ending conversions" window, select "Checkout as-is, commit Unix-style line endings". Alternatively, configure that setting from the command line by running git config --global core.autocrlf input If you will be doing your code editing directly on your Windows host machine (i.e., you are using the Docker container to just run the Habitica server and tests), then select "Checkout Windows-style, commit Unix-style line endings", or configure it by running git config --global core.autocrlf true If you chose one setting now and later decide to change how you do your development work, you can use the appropriate git config --global core.autocrlf ... command to change the setting. For further information on line endings and whitespace in Git, see the "Formatting and Whitespace" section in the Pro Git book. If you don't want to set the core.autocrlf setting globally, see Dealing with line endings > Per-repository settings to learn how to set it for individual repositories. This will only be relevant to you if you are already using Git for other projects or will be using it for others in future. Install Docker #Follow Docker's official instructions for installing docker and docker-compose. #Verify your installation by clicking the Docker Quickstart Terminal icon on your Desktop (Windows) or Launchpad (Mac OS X). #In the Docker Quickstart Terminal, cd to Habitica's top-level directory (the one that contains the config.json.example file). Remain in that directory for all future steps on this page, unless advised otherwise. Use docker-compose to Build and Start Docker Containers Run this command: docker-compose -f docker-compose.dev.yml up -d That command will use Habitica's docker-compose.dev.yml file to build Docker containers to run the various parts of a Habitica install: the server, the website client, and a MongoDB database server. All software needed for those contains will be installed automatically during the build process. If you notice errors, read on to the "Review the Server Output" section below. After the build is complete, if you wish to see the technical details of the three containers, you can run this command: docker ps At this point, the version of Habitica running in the containers is the version that exists in your local clone of your fork of the repository. You can use git installed on your computer to create new branches in your local clone (i.e., do not use git in the container to create branches). You can used any text editor or IDE installed on your computer to edit Habitica's code (i.e., you do not have to use an editor in the container). After you have made changes, you'll need to update the Docker containers as described in the "Restarting the Local Web Server on Docker" section in Using Your Local Install to Modify Habitica's Website and API. If you want to stop the containers, run: docker-compose stop (NB: When you are ready to run Habitica's automatic test suite as described in Using Your Local Install to Modify Habitica's Website and API, that page will show you how to create another Docker container for running the tests.) Category:Contributing